﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using OrganizedIN.BAL;
using OrganizedIN.BussinessServices;
namespace OrganizedIN
{
    public partial class GroupRegistration : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            txtfrstname1.Focus();
        }
        protected void btnregister_Click(object sender, EventArgs e)
        {
            try
            {
                string date;
                BLL registerobj = new BLL();
                UserRegistration setdata = new UserRegistration();
                if (txtemail.Text != "" && txtfrstname1.Text != "" && txtlstname1.Text != "" && txtpassword.Text != "" && chkcondition.Checked && ddlselectgender.SelectedItem.Text != "Select" && ddlselectmonth.SelectedItem.Text != "Month:" && ddlselectday.SelectedItem.Text != "Day:" && ddlselectyear.SelectedItem.Text != "year:")
                {
                    if (txtcompname.Text != "" && txtaddress1.Text != "" && txtaddress2.Text != "" && txtcity.Text != "" && txtstate.Text != "" && txtcountry.Text != "" && txtzipcode.Text != "")
                    {
                        if (txtpassword.Text.Trim() == txtconfrmpassword.Text.Trim())
                        {
                            string url = "confirmation.aspx";
                            setdata.UserEmailID = txtemail.Text;
                            setdata.UserFname = txtfrstname1.Text;
                            setdata.UserLname = txtlstname1.Text;
                            setdata.UserGender = ddlselectgender.SelectedItem.Text.Trim();
                            date = ddlselectmonth.SelectedItem.Text.Trim() + ddlselectday.SelectedItem.Text.Trim() + ',' + ddlselectyear.SelectedItem.Text.Trim();
                            setdata.UserDOB = date;
                            setdata.UserPassword = txtpassword.Text;
                            setdata.UserTimeZone = ddlselecttimezone.SelectedItem.Text.Trim();
                            setdata.UserCompanyName = txtcompname.Text;
                            setdata.UserCompanyCategory = ddlselectcategory.SelectedItem.Text.Trim();
                            setdata.UserAddress = txtaddress1.Text + ' ' + txtaddress2.Text;
                            setdata.UserCity = txtcity.Text;
                            setdata.UserState = txtstate.Text;
                            setdata.UserCountry = txtcountry.Text;
                            setdata.UserZipCode = txtzipcode.Text;
                            setdata.UserPhoneNum = txtcompphoneno.Text;
                            setdata.UserHearAbtOrganizedin = ddlselectmedium.SelectedItem.Text.Trim();
                            setdata.UserAddComment = txtaddcomment.Text;
                            setdata.UserRegistrationDate = System.DateTime.Now;
                            registerobj.GroupRegistrationInsert(setdata);
                            Session["email_username"] = txtemail.Text;
                            Session["PhoneNo"] = txtcompphoneno.Text;
                            ClearField();
                            ClientScript.RegisterStartupScript(this.GetType(), "OpenWin", "<script>OpenConfirmWin('" + url + "')</script>");
                        }
                        else
                        {
                            lblerrmsg.Text = "your password donot match.Plz try again";
                        }
                    }
                    else
                    {
                        lblerrmsg.Text = "Please enter all group information";
                    }
                }
                else
                {
                    lblerrmsg.Text = "Please fill the all personal information fields properly";
                }
            }
            catch (Exception ex)
            {
            }
        }
        protected void ClearField()
        {
            txtfrstname1.Text = "";
            txtlstname1.Text = "";
            txtemail.Text = "";
            txtcompname.Text = "";
            txtcompphoneno.Text = "";
            txtcountry.Text = "";
            txtstate.Text = "";
            txtcity.Text = "";
            txtaddress1.Text = "";
            txtaddress2.Text = "";
            txtaddcomment.Text = "";
            chkcondition.Checked = false;
        }
    }
}
